-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
channel: Remove ptr-to-int casts #764
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
taiki-e
commented
Jan 7, 2022
@@ -177,7 +190,7 @@ impl<T> Channel<T> { | |||
// heap-allocated packet. | |||
packet.wait_ready(); | |||
let msg = packet.msg.get().replace(None).unwrap(); | |||
drop(Box::from_raw(packet as *const Packet<T> as *mut Packet<T>)); | |||
drop(Box::from_raw(token.zero.0 as *mut Packet<T>)); | |||
Ok(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another stacked borrows violation that was fixed by this PR is:
error: Undefined Behavior: trying to reborrow for Unique at alloc5094412+0x8, but parent tag <14690213> does not have an appropriate item in the borrow stack
--> /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/boxed.rs:977:9
|
977 | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to reborrow for Unique at alloc5094412+0x8, but parent tag <14690213> does not have an appropriate item in the borrow stack
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
= note: inside `std::boxed::Box::<crossbeam_channel::flavors::zero::Packet<i32>>::from_raw_in` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/boxed.rs:977:9
= note: inside `std::boxed::Box::<crossbeam_channel::flavors::zero::Packet<i32>>::from_raw` at /Users/taiki/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/boxed.rs:921:18
= note: inside `crossbeam_channel::flavors::zero::Channel::<i32>::read` at /Users/taiki/projects/crossbeam/crossbeam-channel/src/flavors/zero.rs:193:18
= note: inside `crossbeam_channel::flavors::zero::Channel::<i32>::recv` at /Users/taiki/projects/crossbeam/crossbeam-channel/src/flavors/zero.rs:302:24
= note: inside `crossbeam_channel::Receiver::<i32>::recv` at /Users/taiki/projects/crossbeam/crossbeam-channel/src/channel.rs:802:43
note: inside `Chan::<i32>::recv` at crossbeam-channel/tests/golang.rs:64:9
--> crossbeam-channel/tests/golang.rs:64:9
|
64 | r.recv().ok()
| ^^^^^^^^
note: inside closure at crossbeam-channel/tests/golang.rs:1420:28
--> crossbeam-channel/tests/golang.rs:1420:28
|
1420 | l[i] = c.recv().unwrap();
| ^
bors r+ |
Build succeeded: |
bors bot
added a commit
that referenced
this pull request
Jan 8, 2022
769: Prepare for the next release r=taiki-e a=taiki-e - crossbeam-channel 0.5.1 -> 0.5.2 - Fix stacked borrows violations. (#763, #764) - crossbeam-epoch 0.9.5 -> 0.9.6 - Add `Atomic::fetch_update`. (#706) - crossbeam-queue 0.3.2 -> 0.3.3 - Fix stacked borrows violation in `ArrayQueue`. (#763) - crossbeam-utils 0.8.5 -> 0.8.6 - Re-add `AtomicCell<{i,u}64>::{fetch_add,fetch_sub,fetch_and,fetch_or,fetch_xor}` that were accidentally removed in 0.8.0 on targets that do not support `Atomic{I,U}64`. (#767) - Re-add `AtomicCell<{i,u}128>::{fetch_add,fetch_sub,fetch_and,fetch_or,fetch_xor}` that were accidentally removed in 0.8.0. (#767) Co-authored-by: Taiki Endo <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #762 and another stacked borrows violation that seems to have been made detectable by the fix of #762.